package dk.twu.analyzer.model;

import dk.twu.analyzer.core.Window;

import java.time.format.DateTimeFormatter;

/**
 * Created by Tao Wu on 02/06/2015.
 */
public class MatchEntry {
    DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy:MM:dd:HH:mm:ss");
    private final Window window;
    private final String symbolA;
    private final String symbolB;
    private final double correlation;
    private final double valA;
    private final double valB;
    private final double valDiff;
    private final double positiveDiffRatio;
    private final double negativeDiffRatio;

    public MatchEntry(Window window, String symbolA, String symbolB, double correlation, double valA, double valB,
                      double valDiff, double positiveDiffRatio, double negativeDiffRatio) {
        this.window = window;
        this.symbolA = symbolA;
        this.symbolB = symbolB;
        this.correlation = correlation;
        this.valA = valA;
        this.valB = valB;
        this.valDiff = valDiff;
        this.positiveDiffRatio = positiveDiffRatio;
        this.negativeDiffRatio = negativeDiffRatio;
    }

    public Window getWindow() {
        return window;
    }

    public String getSymbolA() {
        return symbolA;
    }

    public String getSymbolB() {
        return symbolB;
    }

    public double getCorrelation() {
        return correlation;
    }

    public double getValA() {
        return valA;
    }

    public double getValB() {
        return valB;
    }

    public double getValDiff() {
        return valDiff;
    }

    public double getPositiveDiffRatio() {
        return positiveDiffRatio;
    }

    public double getNegativeDiffRatio() {
        return negativeDiffRatio;
    }

    @Override
    public String toString() {
        return "MatchEntry{" +
                "valDiff=" + valDiff +
                ", valB=" + valB +
                ", valA=" + valA +
                ", correlation=" + correlation +
                ", symbolB='" + symbolB + '\'' +
                ", symbolA='" + symbolA + '\'' +
                ", window=" + window +
                '}';
    }

    public String toCSVLine() {
        return dateTimeFormatter.format(window.getStartTime()) +
                "," + symbolA +
                "," + symbolB +
                "," + correlation +
                "," + valA +
                "," + valB +
                "," + valDiff +
                "," + positiveDiffRatio +
                "," + negativeDiffRatio +
                System.getProperty("line.separator");
    }
}
